#include <iostream>
#include <openssl/crypto.h>
#include <openssl/bn.h>

int main(int argc, char **argv) {

	static const char num1[] = "18446744073709551616";
	static const char num2[] = "36893488147419103232";

	BIGNUM *bn1 = NULL;
	BIGNUM *bn2 = NULL;

	BN_CTX *ctx = BN_CTX_new();

	BN_dec2bn(&bn1, num1); // convert the string to BIGNUM
	BN_dec2bn(&bn2, num2);

	BN_add(bn1, bn1, bn2); // bn1 = bn1 + bn2
	BN_mul(bn2, bn1, bn2, ctx); // bn2 = bn1 * bn2

	char *result_str = BN_bn2dec(bn1);  // convert the BIGNUM back to string
	char *mul_result_str = BN_bn2dec(bn2);
	
	//printf("%s + %s = %s\n", num1, num2, result_str);
	std::cout << num1 << " + " << num2 << " = " << result_str << std::endl;
	std::cout << num1 << " * " << result_str << " = " << mul_result_str << std::endl;
	OPENSSL_free(result_str);
	OPENSSL_free(mul_result_str);

	BN_free(bn1);
	BN_free(bn2);
	BN_CTX_free(ctx);

	//printf("hello world\n");
	return 0;
}
